From 390350830625c9ea4544959df75c482af819d6d2 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 9 Oct 2003 08:44:10 +0000 Subject: [PATCH] bitkeeper revision 1.497 (3f851fdaCPqNEDqwqkVC4gYJpCZ0pg) dev.c: Allow arbitrary ethernet protocols to transfer between physical network and DOM0,VIF0. --- xen/net/dev.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/xen/net/dev.c b/xen/net/dev.c index ec80189b58..22b81bcc58 100644 --- a/xen/net/dev.c +++ b/xen/net/dev.c @@ -1800,20 +1800,28 @@ int __init net_dev_init(void) return 0; } -inline int init_tx_header(u8 *data, unsigned int len, struct net_device *dev) +inline int init_tx_header(net_vif_t *vif, u8 *data, + unsigned int len, struct net_device *dev) { + int proto = ntohs(*(unsigned short *)(data + 12)); + memcpy(data + ETH_ALEN, dev->dev_addr, ETH_ALEN); - switch ( ntohs(*(unsigned short *)(data + 12)) ) + switch ( proto ) { case ETH_P_ARP: if ( len < 42 ) break; memcpy(data + 22, dev->dev_addr, ETH_ALEN); - return ETH_P_ARP; + break; case ETH_P_IP: - return ETH_P_IP; + break; + default: + /* Unsupported protocols are onyl allowed to/from VIF0/0. */ + if ( (vif->domain->domain != 0) || (vif->idx != 0) ) + proto = 0; + break; } - return 0; + return proto; } @@ -1884,7 +1892,7 @@ static int get_tx_bufs(net_vif_t *vif) g_data = map_domain_mem(tx.addr); protocol = __constant_htons( - init_tx_header(g_data, tx.size, the_dev)); + init_tx_header(vif, g_data, tx.size, the_dev)); if ( protocol == 0 ) { __make_tx_response(vif, tx.id, RING_STATUS_BAD_PAGE); -- 2.30.2